/*
 * GooglePin
 * 
 * Helper Class for generating SRC urls for map pins
 * 
 * */
var GooglePin = {

	key: [
	  { title : "Unknown", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|06c200|000000" },
	  { title : "Food and Drink", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|97ec7d|000000" },
	  { title : "Shopping", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|c89bff|000000" }, 
	  { title : "Entertaining", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|fd8d08|000000" }, 
	  { title : "Events", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|6b98ff|000000" },
	  { title : "Vouchers", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|ffed5c|000000" }, 
	  { title : "Promotions", 
	    src : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=#|cf9fff|000000" }
	],

	shadow: {
	  dfl : "http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
	  star : "http://chart.apis.google.com/chart?chst=d_map_xpin_shadow&chld=pin_star"
	},

	/**
	 * generates image + shadow urls from parameters
	 */
	getPin: function(experience, letter, starred) {

		var src = this.key[experience].src;

		if (starred) { 
			src = src.replace(/d_map_pin_letter/, "d_map_xpin_letter").replace("|000000", "|000000|FF0000");
		}

		if (typeof letter !== "undefined") {
			if (starred) {
				src = src.replace(/#/, "pin_star|"+String.fromCharCode(letter + 65));
			}
			else {
				src = src.replace(/#/, String.fromCharCode(letter + 65));
			}
		}
		else {
			src = src.replace(/#/, '');
		}

		// get shadow
		var shadow = starred ? this.shadow.star : this.shadow.dfl;

		// return name, pin and shadow
		return {
			title: this.key[experience].title, 
			img: src, 
			shadow: shadow
		};
	}
}

// provides...
objx.provides("GooglePin");